Skip to content

Reveal teacher content via eXeLearning's ?exe-teacher URL param, retire CSS injection#86

Merged
erseco merged 3 commits into
mainfrom
fix/teacher-mode-url-param
Jun 26, 2026
Merged

Reveal teacher content via eXeLearning's ?exe-teacher URL param, retire CSS injection#86
erseco merged 3 commits into
mainfrom
fix/teacher-mode-url-param

Conversation

@erseco

@erseco erseco commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Do not merge until exelearning/exelearning#1972 is merged. This PR depends on the core ?exe-teacher=1 contract introduced there; merging earlier would break teacher-mode reveal in the embed.

Why this simplifies the plugin (and where it's heading). Teacher-mode visibility is now driven purely by the package's own ?exe-teacher=1 URL parameter, so the host plugin no longer injects CSS/JS into the embedded package to control it. Beyond removing that injection, this advances the longer-term goal of isolating embedded resource content from the host: because the host no longer reaches into the package DOM, the resource can later be sandboxed / served cross-origin without losing teacher-mode control.

What

eXeLearning core now hides teacher-only content by default and exposes an in-package "teacher layer" selector to show it via the ?exe-teacher=1 URL parameter (upstream exelearning/exelearning#1972, fixes exelearning/exelearning#1772). This consumes that contract and retires the plugin's parent-side teacher-mode CSS injection.

Changes

  • Removed classes/local/ui/teacher_mode_hider.php and the exelearning_require_teacher_mode_hider() lib.php helper that injected #teacher-mode-toggler-wrapper { visibility: hidden } into the package iframe.
  • view.php now appends ?exe-teacher=1 to the content iframe src whenever the per-activity teachermodevisible setting is on — for every viewer.
  • The teachermodevisible setting uses the "Show teacher layer selector" label/help, homogeneous across en/ca/es/eu/gl with mod_exeweb and mod_exescorm. Refreshed the matching install.xml / db/upgrade.php / mod_form.php comments.

Notes

  • The setting alone controls the selector — no capability gate. When on, the in-package selector is available to every viewer; it is OFF by default in the package and the viewer activates it. Presentation mode, not access control.
  • Targets main. No schema change and no version bump — the teachermodevisible field and its default-0 migration already shipped; this only changes how the setting is consumed.

Testing

  • php -l clean; phpcs --standard=moodle clean on the changed files. Behat updated: the iframe src carries exe-teacher=1 when the setting is on (including for a student) and omits it when off; dropped the obsolete hider unit test. PHPUnit/Behat need a Moodle CI site.

Moodle Playground Preview

The changes in this pull request can be previewed and tested using a Moodle Playground instance.

Preview in Moodle Playground

ℹ️ The eXeLearning editor is fetched from the shared release and unpacked into the plugin when the playground boots, so the first load may take a few extra seconds. ELPX upload, viewer and preview work normally.

…njection

eXeLearning packages hide teacher-only content by default and expose a
teacher-layer selector through the package's own ?exe-teacher=1 URL parameter
(upstream exelearning#1772). view.php now appends that parameter to the content
iframe src when the per-activity teachermodevisible setting is on — for every
viewer, with no role gate — instead of injecting CSS into the package to hide
the selector.

- Remove classes/local/ui/teacher_mode_hider.php and the
  exelearning_require_teacher_mode_hider() lib.php helper.
- view.php: append exe-teacher=1 on the content pluginfile URL when the
  teachermodevisible setting is on.
- Homogenize the teachermodevisible label/help ("Show teacher layer selector")
  across en/es/ca/eu/gl, and refresh the install.xml/upgrade/mod_form comments.
- Update behat scenarios (teacher and student see the param when on; neither
  when off) and drop the obsolete hider unit test.
@erseco erseco force-pushed the fix/teacher-mode-url-param branch from 54309a5 to 96df2b4 Compare June 19, 2026 11:53
@erseco erseco changed the base branch from feature/secure-iframe-scorm-bridge to main June 19, 2026 11:53
@codecov-commenter

codecov-commenter commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.48%. Comparing base (4665b64) to head (16e3f9f).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #86      +/-   ##
============================================
- Coverage     89.51%   89.48%   -0.04%     
+ Complexity      980      979       -1     
============================================
  Files            53       52       -1     
  Lines          4236     4221      -15     
============================================
- Hits           3792     3777      -15     
  Misses          444      444              
Flag Coverage Δ
javascript 94.03% <ø> (ø)
php 89.31% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
PHP (server-side) 89.31% <ø> (-0.04%) ⬇️
JavaScript (SCORM tracker) 94.03% <ø> (ø)
Files with missing lines Coverage Δ
lib.php 79.93% <ø> (-0.07%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erseco erseco merged commit 4c33e8a into main Jun 26, 2026
25 checks passed
@erseco erseco deleted the fix/teacher-mode-url-param branch June 26, 2026 12:07
erseco added a commit that referenced this pull request Jun 26, 2026
Reconcile teacher-mode handling with main (#86). main retired the host-side
CSS injection in favour of the package's own ?exe-teacher=1 URL parameter, so:

- view.php: keep the secure/legacy iframe-mode resolution and append
  ?exe-teacher=1 to the resolved $iframeurl when teachermodevisible is on. The
  parameter works in secure (opaque-origin) mode too because the package reads
  its own location.search, so no host CSS injection is needed in either mode.
- Drop the exelearning_require_teacher_mode_hider() call (the helper and
  classes/local/ui/teacher_mode_hider.php were removed on main).
- Retire the SCORM bridge's teacher-mode path, now redundant: remove
  teachermodevisible from the relay config ($relaycfg), the relay handshake
  postMessage and the in-iframe shim's hideTeacherMode() (it injected the exact
  #teacher-mode-toggler-wrapper CSS that #86 retired). Update tests/js
  accordingly. SCORM tracking over the bridge is unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invert Teacher Mode default in exports: hidden by default, opt-in to reveal

2 participants